package com.sun.tool.annotations;

import com.sun.tool.common.Result;

import java.util.List;

/**
 * @Auther: Sunql
 * @Date: 2018/6/11 16:35
 * @Description: 注解校验demo
 */
public class Demo {

    //客户名称
    @EntityClass(regularCheck = Regularity.REGEX_CHINESE, maxLen = 64, attributeName = "名称")
    private String name;

    //电话
    @EntityClass(regularCheck = Regularity.REGEX_MOBILE, message = "电话号码信息必须为11位数字")
    private String tell;

    //地址
    @EntityClass(isNotNull = true, maxLen = 10, attributeName = "地址")
    private String address;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTell() {
        return tell;
    }

    public void setTell(String tell) {
        this.tell = tell;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public static void main(String[] args) {
        Demo demo = new Demo();
        demo.setAddress("山东省济南市历下区凤凰路7704号");
        demo.setName("ASD");
        demo.setTell("GH7485");
        List<Result> results = CheckEntityUtil.check(demo);
        for (Result r : results) {
            System.out.println(r.getCode() + "\t" + r.getMsg());
        }
    }
}
